package com.taofuxn.yycreazy.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.view.View;

import com.taofuxn.yycreazy.R;
import com.taofuxn.yycreazy.ui.base.ToobarActivity;
import com.taofuxn.yycreazy.ui.view.ChooseThemeDialog;
import com.taofuxn.yycreazy.ui.view.RippleView;
import com.taofuxn.yycreazy.util.AppStyleUtil;
import com.taofuxn.yycreazy.util.MyLog;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * 设置app
 * Created by wanghuafu on 16/9/15.
 */
public class SettingActivity extends ToobarActivity implements RippleView.OnRippleCompleteListener {

    @InjectView(R.id.nav_mycollection)
    RippleView navMycollection;
    @InjectView(R.id.switchTheme)
    RippleView switchTheme;
    @InjectView(R.id.suggest)
    RippleView suggest;
    @InjectView(R.id.scoreToUs)
    RippleView scoreToUs;
    @InjectView(R.id.share)
    RippleView share;
    @InjectView(R.id.aboutUs)
    RippleView aboutUs;
    @InjectView(R.id.checkUpdate)
    RippleView checkUpdate;

    @Override
    protected int setContentLayout() {
        return R.layout.activity_setting;
    }

    @Override
    protected void init() {
        navMycollection.setOnRippleCompleteListener(this);
        switchTheme.setOnRippleCompleteListener(this);
        suggest.setOnRippleCompleteListener(this);
        scoreToUs.setOnRippleCompleteListener(this);
        share.setOnRippleCompleteListener(this);
        aboutUs.setOnRippleCompleteListener(this);
        checkUpdate.setOnRippleCompleteListener(this);
    }

    @Override
    public void onComplete(RippleView rippleView) {
        switch (rippleView.getId()) {
            case R.id.nav_mycollection:
                forward(PerConllectionActivity.class);
                break;
            case R.id.switchTheme:
                new ChooseThemeDialog(this).show();
                break;
            case R.id.suggest:
                Snackbar.make(rippleView, "攻城狮们，正在开发中...", Snackbar.LENGTH_SHORT).show();
                break;
            case R.id.scoreToUs:
                Uri uri = Uri.parse("market://details?id=" + getPackageName());
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                break;
            case R.id.share:
                Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                sendIntent.setType("text/*");
                sendIntent.putExtra(Intent.EXTRA_TEXT, "轻松一刻");
                startActivity(sendIntent);
                break;
            case R.id.aboutUs:
                forward(AboutUsActivity.class);
                break;
            case R.id.checkUpdate:
                Snackbar.make(rippleView, "已经是最新版本...", Snackbar.LENGTH_SHORT).show();
                break;
        }
    }


}
